<?php

define("bNoSession", true);
define("spacer", "-------------------------");

ignore_user_abort(1);

print "\n";
print spacer . "\n";

if ( (!isset($argv)) OR (!eregi('index\.php', $argv[0])) )
{
	exit("Can't run the cron routine");
}

define("cronDir", dirname(dirname(dirname(__FILE__))) . "/");

if ( !file_exists(cronDir . "include/init.inc.php") )
{
	exit("Cant load the init file.");
}

require_once cronDir . "include/init.inc.php";

if ( !isset($argv[1]) )
{
	exit("Please specify what job you would like us to do. Example: /var/www/include/cron/index.php databasebackup\n");
}

$oCron = &App::newObject('Cron');

if ( !is_object($oCron) )
{
	exit("Can't load the Cron object!");
}

if ( !$oCron->_checkCron($argv[1]) )
{
	exit("Invalid cron job: ". $argv[1] ."");
}

if ( !file_exists(cronDir . "include/cron/jobs/". $argv[1] .".php") )
{
	exit("We cant find the cron job routine \"". $argv[1] ."\".");
}

$oCron->_print("Starting the phpFoX Cron Job routine at ". date("F j, Y, g:i a", time()) ."");
$oCron->_print("We will be running the \"". $argv[1] ."\" cron job routine");
$oCron->_print(spacer);
$oCron->_execCron($argv[1]);
?>